clear all
set more off
set matsize 2000
cd "D:/Dropbox/coauthors/AMT_Bisbee_Larson/bisbee_larson_replication_final"

********************************************************************************
* File Name: descriptive_replication.do
* 
* Input Files: final_data_clean.csv
* Output Files: summary_stats.dta
*               correlation-long.dta
* Purpose: The purpose of this file is to summarize the raw data for use in 
* Table 2 as descriptive statistics, as well as to produce correlation measures 
* across the dimensions of tie strength measured that are used to create Figure 3
* via the descriptive_results.R script.
********************************************************************************

use ./tools/final_data_clean.dta, clear
*** Summary Statistics (Table 2)
preserve
	keep dem_educ dem_age dem_industry dem_occupation dem_race dem_country dem_family dem_gender dem_hhinc dem_marital introvert online
	foreach var of varlist _all {
	_strip_labels `var'
	}
	saveold ./descriptive/summary_stats.dta, replace
restore


*** Correlation Data
g ind = _n
ren std_jobsearch* st_js*
ren std_contribute* st_cnt*
ren std_garner* st_grn*
ren std_donate* st_dnt*
ren std_personalgain* st_pgn*
ren std_grpgain* st_ggn*
ren std_homo_* st_hm_*
ren std_pers_cris_synth_* st_pecs_*
ren std_pers_succ_synth_* st_pesc_*
ren std_prof_cris_synth_* st_prcs_*
ren std_prof_succ_synth_* st_prsc_*
ren std_interaction_* st_int_*
ren std_tie_synth_* st_strsy_*
ren std_tie_* st_str_*
ren std_seat_synth2_lst_* st_lst_*
ren std_seat_synth2_mst_* st_mst_*

keep st_* prot_peace *_inform_* *_prompt_* online introvert dem_* dem2_* ind
reshape long prot_prompt_ prot_inform_ st_js_ st_cnt_ st_grn_ st_dnt_ st_pgn_ st_ggn_ st_hm_pol_ st_hm_rel_ st_hm_educ_ st_hm_ls_ st_pecs_ st_pesc_ st_prcs_ st_prsc_ st_int_ st_strsy_ st_str_ st_lst_ st_mst_ donate, i(ind) j(tie) string
	
tabulate(tie), g(tie_dum)
ren tie_dum1 clique_dum
ren tie_dum2 strong_dum
ren tie_dum3 strongest_dum
ren tie_dum4 weak_dum
ren tie_dum5 weakest_dum

keep st_*_ *_dum
ren st_hm_*_ homo_*
ren homo_ls homo_class
ren st_dnt_ donate
ren st_js_ info_js
ren st_cnt_ trust_cnt
ren st_grn_ trust_grn
ren st_pgn_ trust_pgn
ren st_ggn_ egal_ggn
ren st_pecs_ int_pers_crs
ren st_pesc_ int_pers_suc
ren st_prcs_ int_prof_crs
ren st_prsc_ int_prof_suc
ren st_int_ inter_pref
ren st_str_ strength_rep
ren st_lst_ comm_lst
ren st_mst_ comm_mst
ren *_dum elic_*
drop elic*
ren st_strsy_ strength_synth
saveold "./descriptive/correlation-long.dta", replace //version(12)
